﻿<%@ Page Language="C#"  MasterPageFile="~/Views/Shared/Site.Master"  Inherits="System.Web.Mvc.ViewPage<PersonalAlbumModel>" %>
<%@ Import Namespace="MyAlbum.Model" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <span id="errorMessage"><%=Html.Encode(Model.ErrorMessage)%></span>
  <%Html.RenderPartial("SlideShow"); %>
<%=Html.Tooltip(MyAlbum.Services.Configuration.ConfigValues.EntriesPerPage)%>
&nbsp;
<%=Html.Tooltip(MyAlbum.Services.Configuration.ConfigValues.EntriesPerRow)%>

    <%
        int itemPerRow = Math.Max(1, Model.Configuration.EntriesPerRow);
            string width = ((90-itemPerRow*4) / itemPerRow).ToString()+"%";
            foreach (var item in Model.Entries)
            {%>
            <div style=" width:<%=width%>" class="entryBox">
              <h1>
                   <%=Html.ActionLink<EntryController>(a=>a.Details(item.Id),Html.Encode(item.Title)) %>
                    <span class="entryTime"><%=item.Date.ToString("MMM d yyyy")%></span>
                    <%if (item.Tags.Count() > 0)
                      { %>
                    <br />
                    <span class="entryTagsTitle"><%=Model.Localize("Entry.Tags")%>:</span>&nbsp;
                <span class="entryTags">
                    <%=Html.Encode(string.Join(",", item.Tags.Select(s => s.Name).ToArray()))%>
                </span>
                <%} %>
              </h1>
                <br />
             
               <%if (Model.Configuration.ShowReplies && (item.Replies.Count() > 0 || System.Diagnostics.Debugger.IsAttached))
                 {%>
                <span class="entryRepliesCount">
                    <%=item.Replies.Count()%>&nbsp;<%=Model.Localize("Entry.Replies")%>
                </span>
                <br />
                 <%} %>
                <a href="<%=Url.Action("Details","Entry",new{id=item.Id}) %>" title="<%=Model.Localize("Entry.View") %>"> <%=item.RenderThumb()%></a>
             <br />
          
        <% if (Model.User.AllowActions())
           {
               %>
                 <%using (Html.BeginForm<EntryController>(a => a.Delete(item.Id), FormMethod.Post, new { id = "formDelete" + item.Id }))
                 { %>
                <%=Html.AntiForgeryToken()%>
                <%=Html.Hidden("returnUrl", Request.RawUrl)%>
               <%} %>
                  <a href="javascript:void(0)" onclick="deleteEntry('<%=item.Id %>')">    
                        <img class="actionImage" src="<%=Html.ThemeItem("Delete.gif")%>" alt="<%=Model.Localize("AddEntry.Delete") %>" title="<%=Model.Localize("AddEntry.Delete") %>" />
                  </a>
                 &nbsp;
                <a href="javascript:void(0)" onclick="showEditEntry('<%=item.Id %>');return false">
                    <img class="actionImage" title="<%=Model.Localize("Entry.Edit") %>" src="<%=Html.ThemeItem("Edit.gif")%>" alt="<%=Model.Localize("Entry.Edit") %>" />
                </a>
           <%}%>
           </div>
            <%} %>
    
  <%if (Model.User.AllowAddEntries())
    {%>
     <a href="javascript:void(0)" onclick="showAddEntry();return false">
        <%=Model.Localize("AddEntry.AddEntry") %>
     </a>
    <%}%>
     <%if (Model.Configuration.EnableSlideShow)
          { %>
  <script type="text/javascript">
          
        $(document).ready(
	        function()
	        {
		        $.ImageBox.init(
			        {
				        loaderSRC: '<%=Html.ThemeItem("ajaxLoader.gif") %>',
				        closeHTML: '<img src="<%=Html.ThemeItem("close.jpg") %>" />'
			        }
		        );
	        }
        );
        </script>
     <%} %>  
  <script type="text/javascript">
  <!--
      function deleteEntry(id) {
            if (confirm("<%=Model.Localize("AddEntry.ConfirmDelete")%>")) {
                document.getElementById('formDelete' + id).submit();
            }
            return false;
        }
        -->
       </script> 
       
        <% if (Model.User.AllowActions())
           {%>
  <script type="text/javascript">
           <!--
           function showAddEntry(){
             $.ajax({
                url:'<%=Url.Action("ShowCreate","Entry",new{parentAlbum= Model.ParentAlbum}) %>',
                method:'post',
                dataType: 'html',
                data:'returnUrl=<%=Html.Encode(Request.RawUrl) %>',
                success:function(t){
                    document.getElementById('editEntryDivContent').innerHTML=t;
                      $('#addEntryForm').validate();
                      document.getElementById('editEntryDivTopContent').innerHTML = '<%=Model.Localize("AddEntry.AddEntry") %>';
                      $('#autoThumb').bind("click",function(e){ document.getElementById('fileThumbData').style.display=this.checked?'none':'block';});
                    $('#editEntryDiv').show();                     
                },error:function(err){
                    alert('<%=Model.Localize("Entry.Error") %>');
                }   
            });
           }
     function showEditEntry(id){
        $.ajax({
            url:'<%=Url.Action("ShowUpdate","Entry",new{id="entryId"}) %>'.replace('entryId',id.toString()),
            metehod:'post',
            dataType: 'html',
            data: 'returnUrl=<%=Html.Encode(Request.RawUrl) %>',
            success:function(t){
                document.getElementById('editEntryDivContent').innerHTML=t;
                  $('#editEntry'+id).validate();
                  document.getElementById('editEntryDivTopContent').innerHTML = '<%=Model.Localize("Entry.Edit")%>';
                  $('#autoThumb').bind("click",function(e){ document.getElementById('fileThumbDataEdit').style.display=this.checked?'none':'block';});
                $('#editEntryDiv').show();                   
            },error:function(err){
                alert('<%=Model.Localize("Entry.Error") %>');
            }   
        });
     }
        -->
    </script>
       
    <div class="window" id="editEntryDiv">
	<div class="windowTop" id="editEntryDivTop" style="background-image:url(<%=Html.ThemeItem("window_top_end.png")%>);">
		<div class="windowTopContent" id="editEntryDivTopContent" style="background-image:url(<%=Html.ThemeItem("window_top_start.png")%>);">
		</div><img class="windowClose" src="<%=Html.ThemeItem("window_close.jpg")%>" id="editEntryDivClose" onclick="$('#editEntryDiv').hide()" alt="missing label :Close" />
	</div><div class="windowBottom" id="editEntryDivBottom" style="background-image:url(<%=Html.ThemeItem("window_bottom_end.png")%>);">
		<div class="windowBottomContent" id="editEntryDivBottomContent" style="background-image:url(<%=Html.ThemeItem("window_bottom_start.png")%>);">
			&nbsp;
		</div>
	</div><div class="windowContent" id="editEntryDivContent">contetn!!
	</div><img class="windowResize" src="<%=Html.ThemeItem("window_resize.gif")%>" id="editEntryDivResize" alt="" />
</div> <script type="text/javascript">
<!--
           $(document).ready(
	function() {
	    $('#editEntryDiv').Resizable(
			{
			    minWidth: 200,
			    minHeight: 200,
			    maxWidth: 600,
			    maxHeight: 800,
			    dragHandle: '#editEntryDivTop',
			    handlers: {
			        se: '#editEntryDivResize'
			    },
			    onResize: function(size, position) {
			        $('#editEntryDivBottom, #editEntryDivBottomContent').css('height', size.height - 33 + 'px');
			        var windowContentEl = $('#editEntryDivContent').css('width', size.width - 25 + 'px');
			        if (!document.getElementById('editEntryDiv').isMinimized) {
			            windowContentEl.css('height', size.height - 48 + 'px');
			        }
			    }
			}
		);
	}
);
-->
</script>
<%} %>
</asp:Content>
